import React, {ComponentClass} from 'react';

import {PropsInterface} from './types';
import {withRouter, RouteComponentProps} from 'react-router-dom';
type CurrentProps = RouteComponentProps & PropsInterface;
class Link extends React.Component<CurrentProps> {
    navigation = () => {
        this.props.history.push(this.props.path);
    };
    render() {
        return React.cloneElement(this.props.children, {
            onClick: this.navigation,
        });
    }
}

export default withRouter<CurrentProps, ComponentClass<CurrentProps>>(Link);
